// 引入 Count的UI组件
import CountUI from '../../components/Count';
// 引入connect用于连接UI组件与redux
import {connect} from "react-redux";

import {
	createIncrementAction,
	createDecrementAction,
	createIncrementAsyncAction} from '../../redux/count_action';

// 映射状态
const mapStateToProps = state => ({count: state});


// 映射状态的方法
// const mapDispatchToProps = dispatch => (
// 	{
// 		jia: number => dispatch(createIncrementAction(number)),
// 		jian: number => dispatch(createDecrementAction(number)),
// 		jiaAsync: (number, time) => dispatch(createIncrementAsyncAction(number, time)),
//
// 	}
// )

// 简写写法
const mapDispatchToProps = {
	jia: createIncrementAction,
	jian: createDecrementAction,
	jiaAsync: createIncrementAsyncAction
}


// 创建并暴露一个Count的容器组件
export default connect(mapStateToProps, mapDispatchToProps)(CountUI);